package pl.com.sthaether.mc.exception;

import org.controlsfx.dialog.Dialog;
import org.controlsfx.dialog.Dialogs;
import pl.com.sthaether.mc.MCApplication;

public class MCExceptionHandler {

    public static void handleException(Throwable exception) {
        exception.printStackTrace();
        MCApplication.logException("Unknown exception: ", exception);
        Dialogs.create().owner(MCApplication.getPrimaryStage()).title("There was some unknown problem...").message("Please contact with author if this problem will repeat (kaqukal@gmail.com)")
                .actions(Dialog.Actions.CLOSE).showException(exception);// in future you could add here button send report
    }

    public static void handleException(MCException exception) {
        exception.printStackTrace();
        MCApplication.logWarn("Known exception handled: " + exception.getTitle());
        exception.doSelectedOperation(Dialogs.create().owner(MCApplication.getPrimaryStage()).title(exception.getTitle()).message(exception.getInfo())
                .actions(exception.getDialogOptions()).showException(exception));
    }
}
